<?php
	include("initialize.php");
?>
<html>
<head>
	<title>GradeGrid - Account Settings</title>
	<?php include("header.php"); ?>
</head>
<body onLoad="writeCopyright()">
	<div class="main">
		
		<?php include("boilerplate.php"); ?>
		<?php include("loginnavigation.php"); ?>
		<?php include("fetchData.php"); ?>
        
		<?php if($_SESSION["logged_in"]): ?>
        	<?php $data=fetchAccountDetails();?>
			<div style="float: left;">
			<span>Personal Settings | <a href="accountSettingsS.php">School Settings</a> | <a href="accountSettingsC.php">Class Settings</a></span>
            <hr />
            <table>
            	<form name="profileSheet" action="editProfile.php" method="post">
				<tr><b>Personal Info</b></tr>
                <tr><td colspan="2"><span style="font-size:11px;">NOTE: Fields marked with an asterisk (*) are REQUIRED.</span></td></tr>
                <tr><td colspan="2"><span style="font-size:11px;">Failure to provide any input on such fields would NOT remove nor change their previous values.</span></td></tr>
                <tr>
                	<td>First Name</td>
                    <td><input name="fname" type="text" value="<?php echo $data['first_name']; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Middle Name</td>
                    <td><input name="mname" type="text" value="<?php echo $data["middle_name"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Last Name</td>
                    <td><input name="lname" type="text" value="<?php echo $data["last_name"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Gender</td>
                    <td><select name="sex">
                    	<?php if($data["sex"]=='M'){?>
                    		<option selected value="M">male</option>
                            <option value="F">female</option>
                        <?php }else{?>
                        	<option value="M">male</option>
                        	<option selected value="F">female</option>
                         <?php }?>
                        </select>
				   	</td>
                </tr>
                <tr>
                	<td>Birthday</td>
                    <td><select name="birthMon">
                            <?php for($i=1; $i<13; $i++) {
                                if(date('n',strtotime($data["birthday"]))==$i)
                                    echo "<option selected value=\"$i\">".date('F',strtotime($i."/1"))."</option>";
                                else
                                    echo "<option value=\"$i\">".date('F',strtotime($i."/1"))."</option>";
                            }?>
                        </select>
                        <select name="birthDay">
							<?php for($i=1; $i<32; $i++) {
                                if(date('j',strtotime($data["birthday"]))==$i)
                                    echo "<option selected value=\"$i\">$i</option>";
                                else
                                    echo "<option value=\"$i\">$i</option>";
                            }?>
                        </select>
						<select name="birthYear">
							<?php for($i=1940; $i<2012; $i++) {
                                if(date('Y',strtotime($data["birthday"]))==$i)
                                    echo "<option selected value=\"$i\">$i</option>";
                                else
                                    echo "<option value=\"$i\">$i</option>";
                            }?>
                        </select>
				   	</td>
                </tr>
                <tr>
                	<td>Country</td>
                    <td><input name="country" type="text" value="<?php echo $data["country"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>City</td>
                    <td><input name="city" type="text" value="<?php echo $data["city_province"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Municipality</td>
                    <td><input name="municipality" type="text" value="<?php echo $data["municipality"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Street</td>
                    <td><input name="street" type="text" value="<?php echo $data["street"]; ?>" style="width:100%"></td>
                </tr>
                <tr><td colspan="2"><b>Contact Information</b></td></tr>
                <tr>
                	<td>E-mail*</td>
                    <td><input name="email" type="text" value="<?php echo $data["email"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Contact Number</td>
                    <td><input name="num" type="text" value="<?php echo $data["contact_number"]; ?>" style="width:100%"></td>
                </tr>
                <tr><td colspan="2"><b>Account Information</b></td></tr>
                <tr>
                	<td>Username*</td>
                    <td><input name="usr" type="text" value="<?php echo $data["username"]; ?>" style="width:100%"></td>
                </tr>
                <tr>
                	<td>Password*</td>
                    <td><input name="pwd" type="text" value="<?php echo $data["password"]; ?>" style="width:100%"></td>
                </tr>
            	<tr><td colspan="2" align="right"><input type="submit" name="submit" value="Update Account"></td></tr>
                </form>
            </table>
			</div>
		<?php else: ?>
			<?php executeFile("../files/access_error.txt"); ?>
		<?php endif ?>
        <?php mysql_close();?>
	</div>
	<div id="copywright"></div>
</body>
</html>